package de.placidi.pressreview.textprocessing;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import edu.stanford.nlp.ling.HasWord;

public final class TextprocessorImpl implements TextProcessor {
	
	private String posTagModel;
	private MyPOSTagger posTagger;
	private List<String> cut;
	private List<String> exclude;
	private File textsource;
	
	public TextprocessorImpl(String posTagModel, File textsource) {
		this.posTagModel = posTagModel;
		this.textsource = textsource;
		posTagger = new MyPOSTagger(posTagModel);
		cut = new ArrayList<String>();
		exclude = new ArrayList<String>();
		
	}
	
	public void addExpressionToCut(String regEx) {
		cut.add(regEx);
	}
	
	public void addExpressionToExclude(String regEx) {
		exclude.add(regEx);
	}
	
	public StatisticWords getStatistics() throws IOException {
		String clean = MyPOSTaggerHelper.readAndCleanText(textsource, cut, exclude);
		List<List<HasWord>> cleanedSentences = posTagger.getSentences(clean);
		List<List<String>> tfsentences = posTagger.getTaggedAndFilteredSentences(cleanedSentences);
		
		StatisticWords stats = new StatisticWords();
		stats = posTagger.getStats(tfsentences);
		return stats;
	}

	public String getPosTagModel() {
		return posTagModel;
	}

	public List<String> getCut() {
		return cut;
	}

	public List<String> getExclude() {
		return exclude;
	}
	
	
}

